package com.pointlion.sys.mvc.admin.evaluate.paperuser;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import com.jfinal.aop.Before;
import com.jfinal.kit.StrKit;
import com.jfinal.plugin.activerecord.Page;
import com.jfinal.plugin.activerecord.Record;
import com.pointlion.sys.interceptor.MainPageTitleInterceptor;
import com.pointlion.sys.mvc.common.base.BaseController;
import com.pointlion.sys.mvc.admin.oa.workflow.WorkFlowService;
import com.pointlion.sys.mvc.common.utils.StringUtil;
import com.pointlion.sys.mvc.common.model.PaperUser;
import com.pointlion.sys.mvc.common.model.SysUser;
import com.pointlion.sys.mvc.common.model.SysOrg;
import com.pointlion.sys.mvc.common.utils.UuidUtil;
import com.pointlion.sys.mvc.common.utils.Constants;
import com.pointlion.sys.mvc.admin.oa.common.OAConstants;
import com.pointlion.sys.mvc.common.utils.DateUtil;
import com.pointlion.sys.plugin.shiro.ShiroKit;



@Before(MainPageTitleInterceptor.class)
public class PaperUserController extends BaseController {
	public static final PaperUserService service = PaperUserService.me;
	public static WorkFlowService wfservice = WorkFlowService.me;
	/***
	 * �б�ҳ��
	 */
	public void getListPage(){
    	render("list.html");
    }
	/***
     * ��ȡ��ҳ����
     **/
    public void listData(){
    	String curr = getPara("pageNumber");
    	String pageSize = getPara("pageSize");
    	String starttime = getPara("starttime");
    	String endtime = getPara("endtime");
    	String search = getPara("search");
    	Page<Record> page = service.getPage(Integer.valueOf(curr),Integer.valueOf(pageSize),starttime,endtime,search);
    	renderPage(page.getList(),"",page.getTotalRow());
    }
    /***
     * ����
     */
    public void save(){
    	PaperUser o = getModel(PaperUser.class);
    	if(StrKit.notBlank(o.getId())){
    		o.update();
    	}else{
    		o.setId(UuidUtil.getUUID());
    		o.setCreateTime(new Date());
    		o.save();
    	}
    	renderSuccess();
    }
    /***
     * ��ȡ�༭ҳ��
     */
    public void getEditPage(){
    	String id = getPara("id");
    	String view = getPara("view");
		setAttr("view", view);
    	if(StrKit.notBlank(id)){//�޸�
    		PaperUser o = service.getById(id);
    		setAttr("o", o);
    	}else{
    		SysUser user = SysUser.dao.findById(ShiroKit.getUserId());
    		SysOrg org = SysOrg.dao.findById(user.getOrgid());
    		setAttr("user", user);
    		setAttr("org", org);
    	}
    	setAttr("formModelName",StringUtil.toLowerCaseFirstOne(PaperUser.class.getSimpleName()));//ģ������
    	render("edit.html");
    }
    /***
     *
     * @throws Exception
     */
    public void delete() throws Exception{
		String ids = getPara("ids");
		service.deleteByIds(ids);
    	renderSuccess("删除成功!");
    }
	/**
	 * 导出excel
	 */
	public void ExportExcel(){
		String ids = getPara("ids");

	}
	/**************************************************************************/
	private String pageTitle = "评价记录";//模块页面标题
	private String breadHomeMethod = "getListPage";//面包屑首页方法

	public Map<String,String> getPageTitleBread() {
		Map<String,String> pageTitleBread = new HashMap<String,String>();
		pageTitleBread.put("pageTitle", pageTitle);
		pageTitleBread.put("breadHomeMethod", breadHomeMethod);
		return pageTitleBread;
	}
}